﻿<%--<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ComeSeeThis_MVC2.Models.Company>>" %>--%>

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ComeSeeThis_MVC2.Models.PaginatedList<ComeSeeThis_MVC2.Models.Company>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Companies
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.RenderPartial("SubMenu"); %>
    <h2>
        Browse Companies</h2>
    <table width="300px">
        <tr>
            <th colspan="2">
                Company
            </th>
            <% if (User.IsInRole("SiteAdmin") || User.IsInRole("ContentAdmin"))
               {%>
            <% }%>
        </tr>
        <%
            foreach (var item in Model)
            {%>
        <tr>
            <td>
                <%:Html.ActionLink(item.CompanyName, "Details", new {id = item.CompanyId})%>
            </td>
            <% if (User.IsInRole("SiteAdmin") || User.IsInRole("ContentAdmin"))
               {%>
            <td align="center">
                <%:Html.ActionLink("Edit", "Edit", new { id = item.CompanyId, q=Request.Url.ToString() })%>
                |
                <%:Html.ActionLink("Delete", "Delete", new { id = item.CompanyId, q = Request.Url.ToString() })%>
            </td>
            <%
                } %>
        </tr>
        <%
            }%>
        <tr>
            <td colspan="2">
                <table width="100%">
                    <tr>
                        <td width="50%">
                            <% if (Model.HasPreviousPage)
                               { %>
                            <%: Html.RouteLink("<<<  Previous",
                                    "Companies",
                            new { page=(Model.PageIndex-1) }) %>
                            <% } %>
                        </td>
                        <td align="right" width="50%">
                            <% if (Model.HasNextPage)
                               { %>
                            <%: Html.RouteLink("Next  >>>",
                                    "Companies",
                            new { page = (Model.PageIndex + 1) })%>
                            <% } %>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
